<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\helpers\Url;
use yii\bootstrap\Modal;
?>

<div style="position:absolute;left:250px;top:50px;height:800px;width:1400px;;">

<div  style="height:900px;width:1130px;position:absolute;left:40px;top:50px;">


    <table id="customers">

        <tr >


            <th>批次ID</th>
            <th>编号</th>

            <th>所属园区</th>
            <th>批次审核时间</th>
            <th>二维码信息</th>
            <th>批次溯源</th>

        </tr>

    <?php foreach($models as $model)
    {
    ?>

        <!--点击产品的批次 进入相应产品的批次信息-->

        <tr  class="alt">


            <td><?=$model->id;?></td>
            <td><?=$model->code;?></td>

            <td><?=$model->product_id;?></td>
            <td><?=$model->audit_time;?></td>
            <td><img src="<?=$model->td_img;?>" alt="comment rank 5" width="100" height="70"></td>
            <td>

                <!--点击批次的溯源档案 进入到批次属于的溯源体系中 并将批次所处的id发送给溯源体系页面-->
                <?= Html::button('溯源档案',['value'=>Url::to("index.php?r=frontend/system/index&id=$model->trace_type_id&id2=$model->id"),'class'=>'btn btn-info','id'=>$model->id,'name'=>'certBtn'])?>

                <?php
                Modal::begin([
                    'header'=>'产品批次溯源档案',
                    'id'=>'modal'.$model->id,
                    'size'=>'modal-lg',

                ]);
                echo "<div id='modalContent$model->id'></div>";

                Modal::end();
                ?>

                <?php
                Modal::begin([
                    'header'=>'产品批次农药使用情况',
                    'id'=>'pesticide'.$model->id,
                    'size'=>'modal-me',

                ]);
                echo "<div id='pesticideContent$model->id'></div>";
                Modal::end();
                ?>

                <?php
                Modal::begin([
                    'header'=>'产品批次肥料使用情况',
                    'id'=>'manure'.$model->id,
                    'size'=>'modal-me',

                ]);
                echo "<div id='manureContent$model->id'></div>";
                Modal::end();
                ?>
            </td>

        </tr>


        <?php
        }
        ?>




    </table>

</div>

</div>

<?php
$js = <<< JS

$(function(){

 $("button[name='certBtn']").each(function(){
    var id = $(this).attr('id');
    $(this).click(function(){

       $('#modal'+id).modal('show')
           .find('#modalContent'+id)
           .load($(this).attr('value'));


   });
 })


});



JS;
$this->registerJs($js);

?>

